package com.ligang.controller;

import com.ligang.domain.Video;
import com.ligang.service.VideoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author: StoneIsLand
 * @Date: 2021/12/15 21:57
 */

@RestController
@RequestMapping("api/v1/video")
public class VideoController {

    @Resource
    private VideoService videoService;

    @GetMapping ("findById")
    public Video findById(Integer id, HttpServletRequest request) {
        Video video = videoService.findById(id);
        video.setServerInfo(request.getServerName()+":"+request.getServerPort());
        return video;
    }

    @PostMapping("save")
    public Video save(@RequestBody Video video) {
        System.out.println(video.getTitle());
        video.setServerInfo("videoController");
        return video;
    }
}

